package com.glsc.ngateway.shortmsg.amqp;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class InitQueue {
    public static final String EXCHANGE = "gateway.exchange.shortmsg.weixin";

    public static final String QUEUE = "gateway.queue.shortmsg.weixin";

    public static final String ROUTING_KEY = "gateway.queue.shortmsg.weixin";

    @Bean
    DirectExchange newExchange() {
        return new DirectExchange(EXCHANGE);
    }

    @Bean
    Queue newQueue() {
        return new Queue(QUEUE, true, false, false);
    }

    @Bean
    public Binding initBinding() {
        return BindingBuilder.bind(newQueue()).to(newExchange()).with(ROUTING_KEY);
    }
}